package com.baofu.paycore.common.utils;

import com.baofu.paycore.common.enums.RedisKeyEnum;
import com.google.common.base.Joiner;
import lombok.extern.slf4j.Slf4j;

/**
 * redis中Key生成工具
 *
 * <p>
 *  1.生成key
 * </p>
 * User: xin deng  Date: 16/4/30 ProjectName: clear Version: 1.0
 */
@Slf4j
public class RedisKeyUtil {

    /**
     * 拼接符
     */
    private static final String SPLICE = ":";

    /**
     * 生成key
     *
     * @param params   参数
     * @return         redis中key
     */
    public static String buildRedisKey(RedisKeyEnum redisKeyEnum, String ...params){
        String key = redisKeyEnum.getCode() + Joiner.on(SPLICE).skipNulls().join(params);
        log.debug("生成redis中Key的参数:{}", key);
        return key;
    }
}
